package net.csdn.business.common.oauth2.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;


/**
 * @Desc: 登录用户信息
 * @ClassName: LoginUser
 * @Author: yourleige@163.com
 * @Date: 2022/9/26 13:42
 */
public class LoginUser extends User {

	private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;

	/**
	 * 用户ID
	 */
	@Getter
	private String id;

	/**
	 * 用户名
	 */
	@Getter
	private String username;

	/**
	 * 姓名
	 */
	/*@Getter
	private String name;*/

	/**
	 * 昵称
	 */
	@Getter
	private String nickname;

	/**
	 * 性别
	 */
	/*@Getter
	private String gender;*/

	/**
	 * 邮箱
	 */
	@Getter
	private String email;

	/**
	 * 头像
	 */
	/*@Getter
	private String avatar;*/

	/**
	 * 设备id
	 */
	@Getter
	private String deviceId;


	@JsonCreator
	public LoginUser(@JsonProperty("id") String id,
                     @JsonProperty("username") String username,
                     //@JsonProperty("username") String name,
                     @JsonProperty("username") String nickname,
                     //@JsonProperty("username") String gender,
                     @JsonProperty("username") String email,
                     //@JsonProperty("username") String avatar,
					 @JsonProperty("deviceId") String deviceId,
                     @JsonProperty("password") String password,
                     @JsonProperty("enabled") boolean enabled,
                     @JsonProperty("accountNonExpired") boolean accountNonExpired,
                     @JsonProperty("credentialsNonExpired") boolean credentialsNonExpired,
                     @JsonProperty("accountNonLocked") boolean accountNonLocked,
                     @JsonProperty("authorities") Collection<? extends GrantedAuthority> authorities) {
		super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
		this.id = id;
		this.username=username;
		//this.name=name;
		this.nickname=nickname;
		//this.gender=gender;
		this.email=email;
		//this.avatar=avatar;
		this.deviceId=deviceId;
	}

}
